package fr.cpe.dp.projet2.rmi.server;

import fr.cpe.dp.projet2.rmi.IRmiMusicService;
import fr.cpe.dp.projet2.rmi.IRmiServerMusicService;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;

public class RmiServerMusicService extends UnicastRemoteObject implements IRmiServerMusicService {
    private HashMap<String, IRmiMusicService> listeServices;

    public RmiServerMusicService(HashMap<String, IRmiMusicService> mapRmiMusicServices) throws RemoteException {
        listeServices = mapRmiMusicServices;
    }

    public Object[] getListeServices() {
        System.out.println("Récupération des noms de services...");
        return listeServices.keySet().toArray();
    }

    public IRmiMusicService getService(Object cleService) throws RemoteException {
        System.out.println("Tentative de récupération du service " + cleService.toString());
        IRmiMusicService leService = (IRmiMusicService) listeServices.get(cleService);
        return leService;
    }
}
